<?php
namespace BP\GPM;
class Dev2Interface {
	public static function Port_Login_String_String ($userNo, $sid) // [String userNo, String sid]
	{
		if ((SystemConfig::getOSDBSrc() == $OSDBSrc->Database))
		{
			$sql = (("SELECT SID FROM Port_Emp WHERE No='" . $userNo) . "'");
			$dt =DBAccess->RunSQLReturnTable($sql);
			if (($dt->Rows->size() == 0))
			{
				throw new \RuntimeException("用户不存在或者SID错误�?");
			}
			if (!$dt->Rows->get(0)->getValue("SID")->equals($sid))
			{
				throw new \RuntimeException("用户不存在或者SID错误�?");
			}
		}
		$emp = Emp::constructor__String($userNo);
		$WebUser->SignInOfGener($emp);
		return ;
	}
	public static function Port_Login_String ($userNo) // [String userNo]
	{
		$emp = Emp::constructor__String($userNo);
		$WebUser->SignInOfGener($emp);
		return ;
	}
	public static function Port_SigOut () 
	{
		$WebUser->Exit();
	}
	public static function Port_SMSInfo ($userNo) // [String userNo]
	{
		$ps = new Paras();
		$ps->SQL = (("SELECT MyPK, EmailTitle  FROM sys_sms WHERE SendToEmpID=" . $SystemConfig->getAppCenterDBVarStr()) . "SendToEmpID AND IsAlert=0");
		$ps->Add("SendToEmpID", $userNo);
		$dt = DBAccess->RunSQLReturnTable($ps);
		$strs = "";
		foreach ($dt->Rows as $dr) 		{
			$strs += ((("@" . $dr->getValue(0)) . "=") . $dr->getValue(1));
		}
		$ps = new Paras();
		$ps->SQL = (("UPDATE  sys_sms SET IsAlert=1 WHERE  SendToEmpID=" . $SystemConfig->getAppCenterDBVarStr()) . "SendToEmpID AND IsAlert=0");
		$ps->Add("SendToEmpID", $userNo);
		DBAccess::RunSQL($ps);
		return $strs;
	}
	public static function DB_Menus ($userNo, $app) // [String userNo, String app]
	{
		$ps = new Paras();
		$ps->SQL = (((("SELECT * FROM GPM_EmpMenu WHERE FK_Emp=" . $SystemConfig->getAppCenterDBVarStr()) . "FK_Emp AND FK_App=") . $SystemConfig->getAppCenterDBVarStr()) . "FK_App ");
		$ps->Add("FK_Emp", $userNo);
		$ps->Add("FK_App", $app);
		return DBAccess->RunSQLReturnTable($ps);
	}
	public static function DB_Apps ($userNo) // [String userNo]
	{
		$ps = new Paras();
		$ps->SQL = (("SELECT * FROM GPM_EmpApp WHERE FK_Emp=" . $SystemConfig->getAppCenterDBVarStr()) . "FK_Emp ");
		$ps->Add("FK_Emp", $userNo);
		return DBAccess->RunSQLReturnTable($ps);
	}
}
?>
